<?php 
include 'conf/configuracion_idioma.php';
include 'conf/common_index.php';
include 'template_include_index.php';
?>

<?php $title = gettext("Vehículos en")." ". PAIS." | ".gettext("Anuncios Locales")?>
<?php $descripcion = gettext("Anuncios Clasificados de Vehículos, Autos, Motos, Camiones, Remolques ...")?>
<?php $keywords = gettext("Anuncios Clasificados de Vehículos, Autos, Motos, Camiones, Remolques ...")?>

<?php include 'template_header_index.php'?>
<?php include 'template_nav_bar_index.php';?>
<?php include 'template/recurso_zebra_pagination_css.php'?>

<?php

	// how many records should be displayed on a page?
	$records_per_page = 8;
	
	// include the pagination class
	require 'zebra-pagination/Zebra_Pagination.php';
	
	// instantiate the pagination object
	$pagination = new Zebra_Pagination();	

    $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM publicaciones WHERE valida = 1 AND tipoanuncio='V' ORDER BY publicacion_id DESC LIMIT " . (($pagination->get_page() - 1) * $records_per_page) . ", " . $records_per_page;
        
     // if query could not be executed
     if (!($result = @mysql_query($sql))) {
     	 
     	// stop execution and display error message
     	die(mysql_error());
     	 
     }
      
     // fetch the total number of records in the table
     $rows = mysql_fetch_assoc(mysql_query('SELECT FOUND_ROWS() AS rows'));
     
     $muestraSoloCapital = false;
     
     if ($rows['rows'] == 0){
     	 
     	$muestraSoloCapital = true;
     	 
     	$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM publicaciones WHERE ciudad_id=-1 AND valida = 1 AND tipoanuncio='V' ORDER BY publicacion_id DESC LIMIT " . (($pagination->get_page() - 1) * $records_per_page) . ", " . $records_per_page;
     	 
     	// if query could not be executed
     	if (!($result = @mysql_query($sql))) {
     		 
     		// stop execution and display error message
     		die(mysql_error());
     		 
     	}
     	 
     	// fetch the total number of records in the table
     	$rows = mysql_fetch_assoc(mysql_query('SELECT FOUND_ROWS() AS rows'));
     	 
     }
      
     // pass the total number of records to the pagination class
     $pagination->records($rows['rows']);
      
     // records per page
     $pagination->records_per_page($records_per_page);
      
     $result = mysql_query($sql);
          
	?>
	

<div class="container">
<div class="row">
	<div class="col-md-12">
	
	<section class="margin-top">	
	 <?php include 'adsense_vertodos_arriba.php'?>
	</section>
	
	<section class="margin-top">
	
	<?php if ($muestraSoloCapital){
	include 'template_no_se_encontraron_anuncios_ciudad.php';
	}?>
	
       <p class="slogan text-center"><span><strong>
        <?php echo gettext("Anuncios Clasificados de Vehículos")?> <?php echo PAIS?>
		</strong></span></p>
   </section>
   
   <section class="margin-bottom">
   	
	 <?php 
	    $cant = 1;
		while ($publicacion = mysql_fetch_array($result)){
			$encontro = true;
			$imagen_path = get_image_thumb_path($publicacion['publicacion_id']);
			$imagenTipoUsuario = getPathImagenTipoUsuario($publicacion['usuario_id']);
			$publicacionId = $publicacion['publicacion_id'];
			$ciudad = get_valores_ciudad($publicacion['ciudad_id'], array("nombre"));	
			$alt = clean_string_with_spaces($publicacion['titulo']);	
			$publicacionPath =  getPublicacionPath($publicacionId);
			$cant = $cant + 1 ;
		?>
				<div class="col-md-6">	
				  <?php include 'content_box_default_list.php';?>
			   	</div>   		   	
			   
			   	
		<?php }?>	   	
		
	
	<div class="col-md-12 text-center">
	<?php $pagination->render();?>
	</div>	
   
    <?php include 'adsense_vertodos_medio.php';?>
   
   	</section>
   
   </div>
   
   
    <section class="margin-top">
        <p class="lead lead-lg text-center primary-color margin-bottom"><strong><?php echo gettext("Anuncios Clasificados Gratis en")?> <?php echo PAIS?></strong></p>
   </section>
   
   <section class="text-center">

	<?php include 'conf/facebook.php';?>
	
   </section>
   
 </div> 
   
</div>

<?php include 'template_footer_index.php'?>
<?php include 'template_sidebar_index.php';?>

<!-- Scripts -->
<!-- Compiled in vendors.js -->
<!--
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.cookie.js"></script>
<script src="assets/js/imagesloaded.pkgd.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/bootstrap-switch.min.js"></script>
<script src="assets/js/wow.min.js"></script>
<script src="assets/js/slidebars.min.js"></script>
<script src="assets/js/jquery.bxslider.min.js"></script>
<script src="assets/js/holder.js"></script>
<script src="assets/js/buttons.js"></script>
<script src="assets/js/jquery.mixitup.min.js"></script>
<script src="assets/js/circles.min.js"></script>
<script src="assets/js/masonry.pkgd.min.js"></script>
<script src="assets/js/jquery.matchHeight-min.js"></script>
-->

<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/vendors.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/funcionesjs.js"></script>

<!-- Syntaxhighlighter -->
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shCore.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shBrushXml.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/syntaxhighlighter/shBrushJScript.js"></script>

<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/app.js"></script>
<script src="http://<?php echo DOMINIO_BASE_COMPLETO?>/js/index.js"></script>

</body>

</html>